/*
 *  Copyright 2010 sonrisa.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package com.zh.jbet.core.dao;

import com.zh.jbet.core.entity.GameContext;
import java.util.List;
import org.eclipse.persistence.queries.QueryByExamplePolicy;

/**
 *
 * @author sonrisa
 */
public class GameContextDao extends GameDao<GameContext> {
    
    @Override
    public List<GameContext> find(GameContext filterEntity, String sort, int start, int count) {
        QueryByExamplePolicy qbe = new QueryByExamplePolicy();
        qbe.alwaysIncludeAttribute(GameContext.class, "parentId");
        return find(filterEntity, qbe, sort, start, count);
    }

    /*
    public List<GameContext> findRootContexts(String sort, int start, int count) {
        //TODO type
        StringBuffer qstr = new StringBuffer("SELECT object(gm) FROM ");
        qstr.append(getEntityClass().getSimpleName());
        qstr.append(" gm WHERE gm.rootId IS NULL ORDER BY gm.nestedId");
        Query q = entityManager.createQuery(qstr.toString());
        q.setFirstResult(start);
        q.setMaxResults(count);
        //TODO sort
        return (List<GameContext>)q.getResultList();
    }
*/
/*
    protected QueryByExamplePolicy getQueryByExamplePolicy() {
        QueryByExamplePolicy qbe = new QueryByExamplePolicy();
        qbe.alwaysIncludeAttribute(GameContext.class, "rootId");
        return qbe;
    }
*/
}
